//
//  BaseAlamofireConfig.swift
//  MT
//
//  Created by zhang qiang on 2018/11/21.
//  Copyright © 2018年 张强. All rights reserved.
//

import UIKit
import Moya
import Alamofire

open class BaseAlamofireConfig: NSObject {

    open func baseAlamofireManager() -> Manager {
        
        let configuration = URLSessionConfiguration.default
        
        configuration.httpAdditionalHeaders = Alamofire.SessionManager.defaultHTTPHeaders
        
        configuration.timeoutIntervalForRequest = 30
        
        let policies: [String: ServerTrustPolicy] = [:
            //"ap.grtstar.cn": .disableEvaluation
        ]
        let manager = Alamofire.SessionManager(configuration: configuration,serverTrustPolicyManager: ServerTrustPolicyManager(policies: policies))
        
        manager.startRequestsImmediately = false
        
        return manager
    }
    
    
    open func baseEndpointMapping<Target: TargetType>(target: Target) -> Endpoint {
        debugPrint("请求连接：\(target.baseURL)\(target.path) \n方法：\(target.method))")
        return MoyaProvider.defaultEndpointMapping(for: target)
    }
    
}
